﻿using System;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Text;
using System.Collections.Generic;

namespace SpiderRelation0720
{
    class CourseRecord
    {
        public int courseWeekS;
        public int courseWeekE;
        public int courseStart;
        public int courseEnd;
        public int courseFloor;
        public int courseName;
        public int courseArea;
        public int courseBuilding;

    }
    class searchClasses
    {
        public List<CourseRecord> AddClasses(string result)
        {

            string classPP = @"周(.*?):(\d)-(\d*)周(.*?)\n(\d*)-(\d*)节,(\d)区,(\d)-((\d).*?);";
            Regex r = new Regex(classPP);
            Match classes = r.Match(result);
            List<CourseRecord> classesList = new List<CourseRecord>();
            while (classes.Success)
            {
                //Console.WriteLine("Match" + (++matchCount));
                CourseRecord temp = new CourseRecord();

                Group weekStart = classes.Groups[2];
                temp.courseWeekS = int.Parse(weekStart.ToString());
                Group weekEnd = classes.Groups[3];
                temp.courseWeekE = int.Parse(weekEnd.ToString());
                Group classStart = classes.Groups[5];
                temp.courseStart = int.Parse(classStart.ToString());
                Group classEnd = classes.Groups[6];
                temp.courseEnd = int.Parse(classEnd.ToString());
                Group classArea = classes.Groups[7];
                temp.courseArea = int.Parse(classArea.ToString());
                Group classBuilding = classes.Groups[8];
                temp.courseBuilding = int.Parse(classBuilding.ToString());
                Group classFloor = classes.Groups[10];
                temp.courseFloor = int.Parse(classFloor.ToString());
                Group className = classes.Groups[9];
                temp.courseName = int.Parse(className.ToString());

                classes = classes.NextMatch();


                // searchAuthor = searchAuthor.NextMatch();
            }
            //foreach (CourseRecord m in classesList)
            // {
            //     Console.WriteLine(m.courseArea);
            // }
            return classesList;
        }
    }
}
